import Crypto from 'crypto-js'

// const AES_KEY = 'Track7182024xx'

const AESCryptoToMd5 = (data: string) => {

  const h = (e: string) => {
    return e += '', Crypto.enc.Utf8.parse(e.padEnd(16, 'ABDEFMN'))
  }
  const parseData = Crypto.enc.Utf8.parse(data)
  const key = h('482737d7ad3f29a2b43e73345830385a')
  const iv = h('TRACK718-QWER788')

  const encrypted = Crypto.AES.encrypt(
    parseData,
    key,
    {
      iv: iv,
      mode: Crypto.mode.ECB,
      padding: Crypto.pad.Pkcs7
    })
  return Crypto.MD5(encrypted.toString()).toString()
}

export {
  AESCryptoToMd5
}
